//package com.tcs.es.sql;
//
//import com.alibaba.druid.pool.DruidDataSource;
//import com.alibaba.druid.pool.ElasticSearchDruidDataSourceFactory;
//import org.apache.http.HttpHost;
//import org.elasticsearch.client.RestClient;
//import org.elasticsearch.client.RestHighLevelClient;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//
//import java.io.IOException;
//import java.sql.*;
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Properties;
//
///**
// * @ClassName : EsSql
// * @Author : 神经刀
// * @Date : 2019/6/6 : 20:08
// * @Version : 1.0
// */
//public class EsSql {
//
//    private final static Logger logger = LoggerFactory.getLogger(EsSql.class);
//
//    private RestHighLevelClient client;
//
//    public static void main(String [] argas) {
//        new EsSql().query();
//    }
//
//    public void query() {
//        Properties properties = new Properties();
//        properties.put("url", "jdbc:elasticsearch://master:9200/mess");
////        properties.put("maxWait","6000000");
////        properties.put("validationQueryTimeout",6000000);
//        DruidDataSource dds = null;
//        Connection connection = null;
//        PreparedStatement ps = null;
//        try {
//            dds = (DruidDataSource) ElasticSearchDruidDataSourceFactory.createDataSource(properties);
//            connection = dds.getConnection();
//            StringBuffer sql = new StringBuffer("SELECT postDate,message,user FROM mess limit 20 ");
////                    .append("from employee")
////                    .append("where last_name = 'bo'");
//            ps = connection.prepareStatement(sql.toString());
//            ResultSet resultSet = ps.executeQuery();
//            List<String> result = new ArrayList<String>();
//            while (resultSet.next()) {
//                logger.info("postDate : {} , message : {} , user : {}" ,
//                        resultSet.getString("postDate") , resultSet.getString("message") , resultSet.getInt("user"));
//            }
//        } catch (Exception e) {
//            logger.error("" , e);
//        } finally {
//            try {
//                ps.close();
//                connection.close();
//                dds.close();
//            } catch (SQLException e) {
//                logger.error("" , e);
//            }
//        }
//    }
//
//    public void insert() {
//        try {
//            client = new RestHighLevelClient(
//                    RestClient.builder(
//                            new HttpHost("master", 9200, "http")));
//
//        } catch (Exception e){
//            logger.error("" , e);
//        } finally {
//            try {
//                client.close();
//            } catch (IOException e) {
//                logger.error("" , e);
//            }
//        }
//    }
//}
